<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class People extends MY_Controller {
	private $new_catgory;
	//构造函数
	public function __construct()
	{
		parent::__construct();
		//获取new下的categorys
		$this->new_catgory = $this->home->get_category_by_id(27);
	}

	public function index(){
		$this->article();
	}

	//首页展示
	public function article()
	{
		$data = array();
		$data['cates'] = $this->new_catgory;
		$data['recentid'] = $this->uri->segment(3);
		//取得第一个元素
		$tmp_cur_name = $this->db->get_where('category',array('cid'=>$data['recentid']))->row_array();
		$data['cur_catname'] = $tmp_cur_name['catname'];
		$data['catname'] = 'people';

		$total = $this->home->get_people_count($data['recentid']);//总条数
		$perpage = 12;                           //每页显示条数
		
		$page = $this->input->get('page');
		$page = @intval($page);
		if($page<=1) $page = 1;
		$this->load->library('page_list',array('total'=>$total,'size'=>$perpage,'page'=>$page));
		$offset=$perpage*($page-1);
		$data['peoples'] = $this->home->get_people_by_cid($data['recentid'],$perpage,$offset);
        $data['pagination'] = $this->page_list->display(site_url('people/article/'.$data['recentid'].'?page=-page-'));

		template('people/index',$data);
	}

	public function info()
	{
		$data = array();
		$data['cates'] = $this->new_catgory;
		$data['recentid'] = $this->uri->segment(3);
		$data['catname'] = 'people';
		$tmp_cur_name = $this->db->get_where('category',array('cid'=>$data['recentid']))->row_array();
		$data['cur_catname'] = $tmp_cur_name['catname'];

		$aid = $this->uri->segment(4);
		$data['pinfo'] = $this->home->get_info_by_peid($aid);
		template('people/peopinfo',$data);
	}

	public function internationalalumni()
	{
		$data = array();
		$data['cates'] = $this->new_catgory;
		$data['recentid'] = $this->uri->segment(3);
		$data['catname'] = 'people';
		$data['cur_catname'] = 'international alumni';
		template('people/alumni',$data);
	}
}